﻿using DevExpress.Xpf.Charts;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;

namespace TeBigCommonUI.Items
{
    /// <summary>
    /// Interaction logic for Bar2D.xaml
    /// </summary>
    public partial class Dount2DChart : SimpleDiagramChartControl
    {
        #region propdp

        public bool SizeEach
        {
            get { return (bool)GetValue(SizeEachProperty); }
            set { SetValue(SizeEachProperty, value); }
        }

        // Using a DependencyProperty as the backing store for SizeEach.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty SizeEachProperty =
            DependencyProperty.Register("SizeEach", typeof(bool), typeof(Dount2DChart), new PropertyMetadata(false));

        #endregion propdp

        public Dount2DChart()
        {
            InitializeComponent();
        }

        protected override Series CreateSeriesFromDataSource(IList<SeriesDataSource> source, int index)
        {
            Pie2DModel model = null;

            if (SizeEach)
                model = FindResource("myCustomPie2DModel") as CustomPie2DModel;
            else
                model = new GlarePie2DModel();

            return new PieSeries2D()
            {
                Model = model,
                HoleRadiusPercent = source[index].HoleRadiusPercent,
            };
        }

        protected override void OnInitChart()
        {
            InitChartInternal(chart, chart_diagram);
        }
    }

    public class DountFlat2DChart : Dount2DChart
    {
        protected override Series CreateSeriesFromDataSource(IList<SeriesDataSource> source, int index)
        {
            return new PieSeries2D()
            {
                Model = new BorderlessFlatPie2DModel(),
                HoleRadiusPercent = source[index].HoleRadiusPercent,
            };
        }
    }

    public class DountSimple2DChart : Dount2DChart
    {
        protected override Series CreateSeriesFromDataSource(IList<SeriesDataSource> source, int index)
        {
            return new PieSeries2D()
            {
                Model = new SimplePie2DModel(),
                HoleRadiusPercent = source[index].HoleRadiusPercent,
            };
        }
    }
}